package com.ls.socketio.repository.dao;

import com.ls.socketio.bean.HotelInfo;
import com.ls.socketio.repository.HotelRepository;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
import sun.rmi.runtime.Log;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author liShan
 * @date 2019/9/3 17:23
 */
@Component
public class HotelRepositoryImpl {

    @Resource
    private HotelRepository hotelRepository;

    /**
     * 添加酒店
     * @param hotelInfo 酒店信息
     */
    public void addHotel(HotelInfo hotelInfo) {
        hotelRepository.save(hotelInfo);
    }

    /**
     * 查询所有的酒店，并按照名字排序
     * @return 酒店的集合
     */
    public List<HotelInfo> selectAll(){
        return hotelRepository.findAll(new Sort(Sort.Direction.ASC, "hotelName"));
    }

}
